
var app = sm("do_App");
var page = sm("do_Page");
var nf = sm("do_Notification");
var http = require("helper/http");
var circleUrl = require("url/circle");

var listdata = mm("do_ListData");
var listview = ui("listView");
listview.bindItems(listdata);

page.on("back", function() {
	app.closePage();
})

/****************处理页面-头部-begin*****************/
var headerAout = ui("headerAout");
var addheader = headerAout.add("header", "source://view/reuse/header.ui", 0, 0);
//左上角-返回
ui(addheader+".headerLeft").on("touch", function() {
    app.closePage()
});
//ui(addheader+".labelTitle").text = "他的圈子";

/****************处理页面-头部-end*****************/
var noData = [{"template":1,"labelContent":"没有加入任何圈子!"}];

var userId = null;
var headTitle = null;
page.on("loaded", function(){
	userId = page.getData().userId;
	headTitle = page.getData().title;
	if(headTitle!=null && headTitle!="" && headTitle!= "undefined"){
		ui(addheader+".labelTitle").text = headTitle;
	}
	getHerCircles();
});


var httpUrl = circleUrl.url.base.herCircles;//她的圈子

//查询【她的圈子】
function getHerCircles() {
	var params = {"userId": userId+""}
	http.post(circleUrl.url.base.herCircles, params, function(data) {
		var circleList = data.circleList;
		if (circleList) {
			listview.rebound();
			listdata.removeAll();
			if(circleList.length > 0){
				listdata.addData(circleList);
			}else{
				listdata.addData(noData);
			}
			listview.refreshItems();
		}
	});
}

//下拉列表
listview.on("pull", function(data) {
	if (data.state == 2) {
		listview.rebound();
	}
});

//上拉列表
listview.on("push", function(data) {
	if (data.state == 2) {
		listview.rebound();
	}
});


